package com.game.gameshoppingcenter.service;

import com.game.gameshoppingcenter.dao.AdminRepository;
import com.game.gameshoppingcenter.entities.Admin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Service
public class AdminService {
    @Autowired
    AdminRepository adminRepository;
    public List<Admin> getAll(){
        return adminRepository.findAll();

    }
    public Admin save(Admin admin){
        return adminRepository.save(admin);
    }
    public boolean login(HttpServletRequest request){
         //从login.html中获得username和password
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        System.out.println(username);
        System.out.println(password);
         Admin admin=adminRepository.login(username,password);
        return admin!=null;
    }
}
